

require('./common');

exports.load = function(req, res){
	var strSQL = "SELECT ID, FormName, Name FROM tblworkspace WHERE FormName <> '' ORDER BY Name ";
	var onClick ='';
	
	conn.query(strSQL, function(err, results, fields){
		if(err) throw err;
		var output = '<table border=0 cellpadding=2 cellspacing=0 width="100%">';
		
		for (var index in results) {
			output += '<tr class="forms">';
			output += '<td width="20px"><img src="/images/report.png"></td>';
		
			
			onClick = "getRequests('"+  results[index].ID + "', '"+  results[index].Name + "','"+  results[index].FormName + "')";
			output += '<td><a onclick="' + onClick +';return false;" style="text-decoration:none;color:#444">' + results[index].FormName + ' Report</a></td>';
			output += '</tr>';
		}
		output += '</table>';
		
		res.send(output)
	});
}


function loadCount(numrec){
	var strSQL = "SELECT COUNT(*) AS NUMREC FROM tbl_purchase_request"
	conn.query(strSQL, function(err, results, fields){
		if(err) throw err;
		for (var index in results) {
			numrec(results[index].NUMREC);
		}
	});
}